/*
*	Title: tcptoken.h
*	
*	Code that abstracts a connection library to be used 
*	on our assignment. This lib encapsulates the definitions of a TCP
*	connection and how to set on up.
*
*	Date: 22/09/2013
*	Autors: Danilo Barbosa Porto , Henrique Alberto Rusa
*/

#ifndef _TCPTOKEN_H_
#define _TCPTOKEN_H_

#include<netdb.h>

#define QUEUESIZE 10

typedef struct serv{
	int socket;
	int newSocket;
	int portNumber;
	int	clientLenght;
	struct sockaddr_in server_address; 
	struct sockaddr_in client_address;
} *servtoken ;

typedef struct client{
	int socket;
	int	portNumber;
	struct sockaddr_in server_address;
	struct hostent *server;
} *clientoken ;

void newServer(servtoken *Server, int portno);

void serverStart(servtoken *Server);

int serverRead(servtoken *Server, void *buffer, int ByteSize);

int serverWrite(servtoken *Server, void *buffer, int ByteSize);

int closeServer(servtoken *Server);

void newClient(clientoken *Client, int portno, char *hostname);

void clientStart(clientoken *Client);

int clientRead(clientoken *Client, void *buffer, int ByteSize);

int clientWrite(clientoken *Client, void *buffer, int ByteSize);

int closeClient(clientoken *Client);

#endif